

import UIKit

class NotifyName:NSObject
{
    /// 更新类型
    @objc static let updateType = "updateType"
    /// 更新明细
    @objc static let updateRecord = "updateRecord"

    @objc static let updateUser = "updateUser"

}

class NotifyTool:NSObject {
    
    /// 添加通知
    /// - Parameters:
    ///   - observer: 观察者
    ///   - select: 方法
    ///   - namt: 通知name
    ///   - object: obj
    @objc class func add(_ observer:Any, _ select:Selector, _ name:String, _ object:Any?=nil)
    {
        NotificationCenter.default.addObserver(observer, selector:select, name:Notification.Name(name), object: object)
    }
    
    @objc class func add(_ observer:Any, _ select:Selector, _ name:String)
    {
        NotificationCenter.default.addObserver(observer, selector:select, name:Notification.Name(name), object:nil)
    }
    
    /// 发送通知
    /// - Parameters:
    ///   - name: name
    ///   - userInfo: userinfo
    ///   - objc: objc
    @objc class func post(_ name:String,_ userInfo:[String:Any]?=nil, _ objc:Any?=nil)
    {
        NotificationCenter.default.post(name: NSNotification.Name(name), object: objc, userInfo: userInfo)
    }
    
    /// 发送通知
    /// - Parameters:
    ///   - name: name
    ///   - objc: objc
    @objc class func post(_ name:String,_ objc:Any?=nil)
    {
        NotificationCenter.default.post(name:NSNotification.Name(name), object:objc)
    }
    
    @objc class func post(_ name:String)
    {
        NotificationCenter.default.post(name:NSNotification.Name(name), object:nil)
    }
    
    @objc class func remove(_ objc:Any?=nil)
    {
        NotificationCenter.default.removeObserver(objc!)
    }
}
